package androidx.recyclerview.widget;

import androidx.recyclerview.widget.RecyclerView;
import b.d.d;
import b.d.g;
import b.f.k.e;
import b.f.k.f;

class t {

    /* renamed from: a  reason: collision with root package name */
    final g<RecyclerView.d0, a> f1039a = new g<>();

    /* renamed from: b  reason: collision with root package name */
    final d<RecyclerView.d0> f1040b = new d<>();

    static class a {

        /* renamed from: d  reason: collision with root package name */
        static e<a> f1041d = new f(20);

        /* renamed from: a  reason: collision with root package name */
        int f1042a;

        /* renamed from: b  reason: collision with root package name */
        RecyclerView.l.c f1043b;

        /* renamed from: c  reason: collision with root package name */
        RecyclerView.l.c f1044c;

        private a() {
        }

        static void a() {
            do {
            } while (f1041d.b() != null);
        }

        static a b() {
            a b2 = f1041d.b();
            return b2 == null ? new a() : b2;
        }

        static void c(a aVar) {
            aVar.f1042a = 0;
            aVar.f1043b = null;
            aVar.f1044c = null;
            f1041d.a(aVar);
        }
    }

    interface b {
        void a(RecyclerView.d0 d0Var);

        void b(RecyclerView.d0 d0Var, RecyclerView.l.c cVar, RecyclerView.l.c cVar2);

        void c(RecyclerView.d0 d0Var, RecyclerView.l.c cVar, RecyclerView.l.c cVar2);

        void d(RecyclerView.d0 d0Var, RecyclerView.l.c cVar, RecyclerView.l.c cVar2);
    }

    t() {
    }

    private RecyclerView.l.c l(RecyclerView.d0 d0Var, int i) {
        a m;
        RecyclerView.l.c cVar;
        int f = this.f1039a.f(d0Var);
        if (f >= 0 && (m = this.f1039a.m(f)) != null) {
            int i2 = m.f1042a;
            if ((i2 & i) != 0) {
                m.f1042a = (~i) & i2;
                if (i == 4) {
                    cVar = m.f1043b;
                } else if (i == 8) {
                    cVar = m.f1044c;
                } else {
                    throw new IllegalArgumentException("Must provide flag PRE or POST");
                }
                if ((m.f1042a & 12) == 0) {
                    this.f1039a.k(f);
                    a.c(m);
                }
                return cVar;
            }
        }
        return null;
    }

    /* access modifiers changed from: package-private */
    public void a(RecyclerView.d0 d0Var, RecyclerView.l.c cVar) {
        a aVar = this.f1039a.get(d0Var);
        if (aVar == null) {
            aVar = a.b();
            this.f1039a.put(d0Var, aVar);
        }
        aVar.f1042a |= 2;
        aVar.f1043b = cVar;
    }

    /* access modifiers changed from: package-private */
    public void b(RecyclerView.d0 d0Var) {
        a aVar = this.f1039a.get(d0Var);
        if (aVar == null) {
            aVar = a.b();
            this.f1039a.put(d0Var, aVar);
        }
        aVar.f1042a |= 1;
    }

    /* access modifiers changed from: package-private */
    public void c(long j, RecyclerView.d0 d0Var) {
        this.f1040b.j(j, d0Var);
    }

    /* access modifiers changed from: package-private */
    public void d(RecyclerView.d0 d0Var, RecyclerView.l.c cVar) {
        a aVar = this.f1039a.get(d0Var);
        if (aVar == null) {
            aVar = a.b();
            this.f1039a.put(d0Var, aVar);
        }
        aVar.f1044c = cVar;
        aVar.f1042a |= 8;
    }

    /* access modifiers changed from: package-private */
    public void e(RecyclerView.d0 d0Var, RecyclerView.l.c cVar) {
        a aVar = this.f1039a.get(d0Var);
        if (aVar == null) {
            aVar = a.b();
            this.f1039a.put(d0Var, aVar);
        }
        aVar.f1043b = cVar;
        aVar.f1042a |= 4;
    }

    /* access modifiers changed from: package-private */
    public void f() {
        this.f1039a.clear();
        this.f1040b.b();
    }

    /* access modifiers changed from: package-private */
    public RecyclerView.d0 g(long j) {
        return this.f1040b.f(j);
    }

    /* access modifiers changed from: package-private */
    public boolean h(RecyclerView.d0 d0Var) {
        a aVar = this.f1039a.get(d0Var);
        return (aVar == null || (aVar.f1042a & 1) == 0) ? false : true;
    }

    /* access modifiers changed from: package-private */
    public boolean i(RecyclerView.d0 d0Var) {
        a aVar = this.f1039a.get(d0Var);
        return (aVar == null || (aVar.f1042a & 4) == 0) ? false : true;
    }

    /* access modifiers changed from: package-private */
    public void j() {
        a.a();
    }

    public void k(RecyclerView.d0 d0Var) {
        p(d0Var);
    }

    /* access modifiers changed from: package-private */
    public RecyclerView.l.c m(RecyclerView.d0 d0Var) {
        return l(d0Var, 8);
    }

    /* access modifiers changed from: package-private */
    public RecyclerView.l.c n(RecyclerView.d0 d0Var) {
        return l(d0Var, 4);
    }

    /* access modifiers changed from: package-private */
    public void o(b bVar) {
        RecyclerView.l.c cVar;
        RecyclerView.l.c cVar2;
        for (int size = this.f1039a.size() - 1; size >= 0; size--) {
            RecyclerView.d0 i = this.f1039a.i(size);
            a k = this.f1039a.k(size);
            int i2 = k.f1042a;
            if ((i2 & 3) != 3) {
                if ((i2 & 1) != 0) {
                    cVar = k.f1043b;
                    if (cVar != null) {
                        cVar2 = k.f1044c;
                    }
                } else {
                    if ((i2 & 14) != 14) {
                        if ((i2 & 12) == 12) {
                            bVar.d(i, k.f1043b, k.f1044c);
                        } else if ((i2 & 4) != 0) {
                            cVar = k.f1043b;
                            cVar2 = null;
                        } else if ((i2 & 8) == 0) {
                        }
                        a.c(k);
                    }
                    bVar.b(i, k.f1043b, k.f1044c);
                    a.c(k);
                }
                bVar.c(i, cVar, cVar2);
                a.c(k);
            }
            bVar.a(i);
            a.c(k);
        }
    }

    /* access modifiers changed from: package-private */
    public void p(RecyclerView.d0 d0Var) {
        a aVar = this.f1039a.get(d0Var);
        if (aVar != null) {
            aVar.f1042a &= -2;
        }
    }

    /* access modifiers changed from: package-private */
    public void q(RecyclerView.d0 d0Var) {
        int m = this.f1040b.m() - 1;
        while (true) {
            if (m < 0) {
                break;
            } else if (d0Var == this.f1040b.n(m)) {
                this.f1040b.l(m);
                break;
            } else {
                m--;
            }
        }
        a remove = this.f1039a.remove(d0Var);
        if (remove != null) {
            a.c(remove);
        }
    }
}
